/***************************************************************************
 * 文件名:ResultsDTO.java<br>
 * 版本: <br>
 * 描述: <br>前后台通讯返回的公共类
 * 版权所有: <br>
 * //////////////////////////////////////////////////////// <br>
 * 创建者: robo<br>
 * 创建日期: 2010-11-27 <br>
 * 修改者: <br>
 * 修改日期: <br>
 * 修改说明: <br>
 **************************************************************************/
package com.sunwayhorizo.health.business.dto;

import java.io.Serializable;

public class ResultsDTO implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	//返回标志(true/false)
	private boolean resultFlag;
	
	//返回结果主体 例如：查询时 返回实体或实体list新增时 返回后台生成的ID等
	private Object object;
	
	//描述信息
	private String resultDesc;
	
	//查询结果总行数
	private int  totalRecords;
	
	//当前第几页
	private int toPage;
	
	//每页显示记录数
	private int pageSize;
		
	//起始记录数
	private int beginIndex;
	
	//友好错误提示
	private String resultErrorText;
	
	public ResultsDTO(){
		
	}
	
	

	public ResultsDTO(boolean resultFlag, Object object, String resultDesc) {
		super();
		this.resultFlag = resultFlag;
		this.object = object;
		this.resultDesc = resultDesc;
	}



	@Override
	public String toString() {
		return "ResultsDTO [\n返回标志=" + resultFlag + ",\n 返回结果主体="
				+ object + ",\n 描述信息=" + resultDesc + ",\n 查询结果总行数="
				+ totalRecords + ",\n 当前第几页=" + toPage + ",\n 每页显示记录数="
				+ pageSize + ",\n 起始记录数=" + beginIndex
				+ ",\n 友好错误提示=" + resultErrorText + "]";
	}



	public ResultsDTO(int toPage, int pageSize){
		// 判断当前页是否为0
		if (toPage == 0) {
			// 如为0 将当前页修改为1
			this.toPage = 1;
		} else {
			this.toPage = toPage;
		}
		this.pageSize = pageSize;
	}

	public boolean getResultFlag() {
		return resultFlag;
	}

	public void setResultFlag(boolean resultFlag) {
		this.resultFlag = resultFlag;
	}

	public Object getObject() {
		return object;
	}

	public void setObject(Object object) {
		this.object = object;
	}

	public String getResultDesc() {
		return resultDesc;
	}

	public void setResultDesc(String resultDesc) {
		this.resultDesc = resultDesc;
	}

	public int getTotalRecords() {
		return totalRecords;
	}

	public void setTotalRecords(int totalRecords) {
		this.totalRecords = totalRecords;
	}

	public int getToPage() {
		return toPage;
	}

	public void setToPage(int toPage) {
		this.toPage = toPage;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getBeginIndex() {
		if(toPage <= 0 ){
			toPage = 1;
		}
		beginIndex = (toPage - 1) * pageSize;
		return beginIndex;
	}

	public void setBeginIndex(int beginIndex) {
		this.beginIndex = beginIndex;
	}

	public String getResultErrorText() {
		return resultErrorText;
	}

	public void setResultErrorText(String resultErrorText) {
		this.resultErrorText = resultErrorText;
	}
	
	

}


